<template>
	<view class="page">
		<image class="fs-full" src="/static/kh.png" mode="widthFix"></image>

		<view class="fs-full fs-py32">
			<fui-card>
				<fui-form ref="form1" labelWidth="200" labelColor='#666'>
					<customerTypePicker v-model:customer_type="formData.customer_type" />

					<fui-form-item label="公司名称" asterisk>
						<fui-input v-model="formData.company_name" placeholder="请输入公司名称" :borderBottom="false"
							:padding="[0]"></fui-input>
					</fui-form-item>

					<fui-form-item label="客户姓名" asterisk>
						<fui-input v-model="formData.customer_name" placeholder="请输入客户姓名" :borderBottom="false"
							:padding="[0]"></fui-input>
					</fui-form-item>

					<companyTypePicker v-model:customer_category="formData.customer_category" />
				</fui-form>
			</fui-card>
		</view>
	</view>
</template>

<script setup>
	import { inject, ref } from 'vue';
	import customerTypePicker from './customerTypePicker.vue';
	import companyTypePicker from './companyTypePicker.vue';

	const formData = inject('formData')

	const rules = [
		{ name: 'customer_type', rule: ['required'], msg: ['请选择客户类型'] },
		{ name: 'company_name', rule: ['required'], msg: ['请输入公司名称'] },
		{ name: 'customer_name', rule: ['required'], msg: ['请输入客户姓名'] },
		{ name: 'customer_category', rule: ['required'], msg: ['请选择公司类型'] },
	]

	const form1 = ref(null)
	defineExpose({ submit })
	async function submit() {
		const res = await form1.value.validator(formData.value, rules)
		return res
	}
</script>

<style>
</style>